package com.leapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}
	
	//faz o login do usuário
	public void login(View view){
		//Se o usuário não existe mostre um toast
		TextView username = (TextView) findViewById(R.id.username);
		TextView pass = (TextView) findViewById(R.id.pass);
		
		if(!username.getText().equals(pass.getText())) { //loga o usuario caso tudo ok	
			Usuario usuario = Usuario.getInstancia();
			usuario.setUsername(username.getText().toString());
			usuario.baixarListaQuestionarios();
			
			//Prepara a página de seleção de questionarios
			Intent login_selecao = new Intent(this,SelecaoActivity.class);
			startActivity(login_selecao);
		}
	}

}
